package Controller.Goods;


import Service.GoodsService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet(name = "deleteGoods", value = "/deleteGoods")
public class DeleteGoods extends HttpServlet {
    private GoodsService goodsService = new GoodsService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Integer id = Integer.valueOf(request.getParameter("id"));
        try{
            goodsService.deleteGoods(id);
            request.getRequestDispatcher("/ListGoods").forward(request,response);
        }catch (SQLException e){
            e.printStackTrace();
        }
    }
}